<?php
/**
 * 统计Service
 */

declare (strict_types=1);

namespace app\api\service;

use app\common\model\Tongji;
use app\api\exception\ApiServiceException;
use think\db\exception\{DbException, ModelNotFoundException, DataNotFoundException};

class TongjiService extends ApiBaseService
{
    protected Tongji $model;

    public function __construct()
    {
        $this->model = new Tongji();
    }

        /**
     * 列表
     * @param $param
     * @param $page
     * @param $limit
     * @return array
     * @throws ApiServiceException
     */
    public function getList($param, $page, $limit): array
    {
        try {
            $field = 'id,user_id,type_id,parent_id,num,spec_id,brand_id,price,money,create_time';
            $data  = $this->model
                ->scope('ApiWhere', $param)
                ->page($page, $limit)
                ->field($field)
                ->select()
                ->toArray();
        } catch (DataNotFoundException | ModelNotFoundException $e) {
            $data = [];
        } catch (DbException $e) {
            throw new ApiServiceException('查询列表失败，信息' . $e->getMessage());
        }

        return $data;
    }
    
    
    
    
    
    
    
    
    
    
    
    
}
